﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Ppt = Microsoft.Office.Interop.PowerPoint;

namespace ObjectModel.PowerPoint.New
{
    public class ResolvableTableCellShape : ResolvableObject
    {
        Ppt.Cell mCell;
        
        public ResolvableTableCell StoredCell { get; set; }

        public ResolvableTableCellShape() { } // Parameterless constructor required for deserialization.
        
        public ResolvableTableCellShape(Ppt.Table table, int row, int col)
        {
            StoredCell = new ResolvableTableCell(table, row, col);
        }

        [XmlIgnore]
        Ppt.Cell Cell
        {
            get
            {
                if (mCell == null)
                    mCell = StoredCell.Resolve() as Ppt.Cell;
                
                return mCell;
            }
        }

        [XmlIgnore]
        public ResolvableShape ParentShape { get { return StoredCell.Shape; } }

        public override object Resolve()
        {
            return Cell.Shape;
        }

        public bool Selected
        {
            get
            {
                return Cell.Selected;
            }
        }
    }
}
